<!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script type="text/javascript" src="https://sandbox.google.com/checkout/inapp/lib/buy.js"></script>
        <script type="text/javascript">
            var generatedJwt = {
                "iss": "1337133713371337",
                "aud": "Google",
                "typ": "google/payments/inapp/item/v1",
                "exp": "1309988959",
                "iat": "1409988959",
                "request": {
                    "name": "Piece of Cake",
                    "description": "Virtual chocolate cake to fill your virtual tummy",
                    "price": "10.50",
                    "currencyCode": "USD",
                    "sellerData": "user_id:1224245,offer_code:3098576987,affiliate:aksdfbovu9j"
                }
            };

            function purchase() {
                google.payments.inapp.buy({
                    'jwt': generatedJwt,
                    'success': successPurchaseHandler,
                    'failure': failPurchaseHandler
                });
            }

            function successPurchaseHandler(e) {
                console.log("success");
                console.log(e);
            }

            function failPurchaseHandler(e) {
                console.log("fail");
                console.log(e);
            }

        </script>
    </head>
<body onload="setup()">
        <button name="buy_button" onclick="purchase()">Purchase</button>
        <div class="google_gen_test">
        <script src="https://sandbox.google.com/checkout/inapp/lib/buy.js"></script><script type="text/javascript">
function setup() {
runDemoButton = document.getElementById("runDemoButton");
runDemoButton.onclick = function () {
    google.payments.inapp.buy({
        parameters: {},
        jwt: "eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIxNDIwNDk" +
            "1MzA5NDM1MjE2ODU3MSIsImF1ZCI6Ikdvb2dsZSI" +
            "sInR5cCI6Imdvb2dsZS9wYXltZW50cy9pbmFwcC9" +
            "pdGVtL3YxIiwiaWF0IjoxMzYyMzc0NTgxLCJleHA" +
            "iOjEzNjIzODA1ODEsInJlcXVlc3QiOnsibmFtZSI" +
            "6IlBpZWNlIG9mIENha2UiLCJkZXNjcmlwdGlvbiI" +
            "6IkEgZGVsaWNpb3VzIHBpZWNlIG9mIHZpcnR1YWw" +
            "gY2FrZSIsInByaWNlIjoiMTAuNTAiLCJjdXJyZW5" +
            "jeUNvZGUiOiJVU0QiLCJzZWxsZXJEYXRhIjoiWW9" +
            "1ciBEYXRhIEhlcmUifX0.GKUNa7PZ8RnSeaYTzeL" +
            "l2BKaPT8vSzLWezjh3S_0Xaw",
        success: function () { window.alert("success") },
        failure: function () { window.alert("failure") }
    });
    return false;
};
}
</script>
        </div>
      <button id="runDemoButton" value="buy"><b>Purchase</b></button>
    </body>
</html>